package com.liu.wode.controller;

import com.liu.wode.mapper.RoomSortMapper;
import com.liu.wode.mapper.RoomsMapper;
import com.liu.wode.pojo.RoomSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class DateShowController {
    @Autowired
    RoomsMapper roomsMapper;
    @Autowired
    RoomSortMapper roomSortMapper;
    @RequestMapping("/ShowDate")
    @ResponseBody
    public Object ShowDate(){
        List<RoomSort> roomSorts = roomSortMapper.queryRoomSortList();
        for (RoomSort roomSort : roomSorts) {
            roomSortMapper.updateRoomSort(new RoomSort(roomSort.getRoomsort(),roomsMapper.sortSum(roomSort.getRoomsort())));
        }
        System.out.println(roomSortMapper.queryRoomSortList());
        return roomSortMapper.queryRoomSortList();
    }
}
